package com.oscar.ehome.utils.system;

import android.content.Context;
import android.content.SharedPreferences;

import com.oscar.ehome.bean.loginbean.UserBean;

import static android.content.Context.MODE_PRIVATE;

/**
 * 缓存数据
 */
public class SystemConfig implements ISystemConfig {
    public final static String CONFIG_FILENAME = "appbase";
    private Context context;
    private SharedPreferences systemConfigSharedPreferences;

    /**
     * 用户ID
     */
    public final static String ID = "id";
    /**
     * 用户token
     */
    public final static String TOKEN = "token";
    /**
     * 用户名
     */
    public final static String USERNAME = "username";
    /**
     * 性别
     */
    public final static String USERSEX = "usersex";
    /**
     * 身份证号
     */
    public final static String USERIDCARD = "useridcard";
    /**
     * 头像
     */
    public final static String USERIMG = "userimg";
    /**
     * 用户
     */
    public final static String EXCLUSICESRC = "exclusiceSrc";
    /**
     * 是否认证
     */
    public final static String IMAGENAME = "imagename";
    /**
     * 用户等级
     */
    public final static String JOBLEVEL = "joblevel";
    /**
     * 用户是否登录
     */
    public final static String ISLOGIN = "islogin";
    /**
     * 登录信息
     */
    public final static String LOGINMESSAGE = "loginmessage";
    /**
     * 是否认证
     */
    public final static String STATUS = "status";
    /**
     * 头像名字
     */
    public final static String IMAGNAME = "imagname";
    /**
     * 主题颜色
     */
    public final static String COLOR = "color";
    /**
     * 首页应用管理所有应用
     */
    public final static String APPLATIONS = "appaltions";
    public final static String YaoQing = "false";
    /**
     * 首页应用管理所有应用
     */
    public final static String APPLATIONSS = "appaltionss";
    /**
     * 添加的应用
     */
    public final static String ADDAPP = "addapp";
    /**
     * 删除的应用
     */
    public final static String DELETEAPP = "deleteapp";

    /**
     * 用户基本信息
     */
    public final static String USERMESSAGE = "usermessage";
    /**
     * 是否是第一次进入
     */
    public final static String ISFIRST = "isfirst";
    /**
     * 是否是管理员
     */
    public final static String ISMANGET = "ismanger";

    /**
     * 保险表单
     */
    public final static String INSURANCE = "insurance";


    public SystemConfig(Context ctx) {
        this.context = ctx;
        SharedPreferences sp = this.context.getSharedPreferences(
                CONFIG_FILENAME, MODE_PRIVATE);
        this.setSystemConfigSharedPreferences(sp);
    }

    public SharedPreferences getSystemConfigSharedPreferences() {
        return systemConfigSharedPreferences;
    }

    public void setSystemConfigSharedPreferences(
            SharedPreferences systemConfigSharedPreferences) {
        this.systemConfigSharedPreferences = systemConfigSharedPreferences;
    }

    @Override
    public void setIsFirst(boolean isFirst) {
        this.getSystemConfigSharedPreferences().edit()
                .putBoolean(ISFIRST, isFirst).commit();
    }

    @Override
    public boolean getIsFirst() {
        return this.getSystemConfigSharedPreferences().getBoolean(ISFIRST,
                false);
    }

    @Override
    public void setColor(String color) {
        this.getSystemConfigSharedPreferences().edit()
                .putString(COLOR, color).commit();
    }

    @Override
    public String getColor() {
        return this.getSystemConfigSharedPreferences().getString(COLOR, "");
    }

    @Override
    public void setAppaction(String apption) {
        this.getSystemConfigSharedPreferences().edit()
                .putString(APPLATIONS, apption).commit();
    }

    @Override
    public String getAppaction() {
        return this.getSystemConfigSharedPreferences().getString(APPLATIONS, "");
    }

    @Override
    public void setyaoqing(String yaoqing) {
        this.getSystemConfigSharedPreferences().edit()
                .putString(YaoQing, yaoqing).commit();
    }

    @Override
    public String getyaoqing() {
        return this.getSystemConfigSharedPreferences().getString(YaoQing, "");
    }

    @Override
    public void setAppactionnum(int apption) {
        this.getSystemConfigSharedPreferences().edit()
                .putInt(APPLATIONSS, apption).commit();
    }

    @Override
    public int getAppactionnum() {
        return this.getSystemConfigSharedPreferences().getInt(APPLATIONSS, 4);
    }

    @Override
    public void setIsMaanger(String isManger) {
        this.getSystemConfigSharedPreferences().edit()
                .putString(ISMANGET, isManger).commit();
    }

    @Override
    public String getManfer() {
        return this.getSystemConfigSharedPreferences().getString(ISMANGET, "");
    }

    @Override
    public void setUserBean(String userBean) {
        this.getSystemConfigSharedPreferences().edit()
                .putString(LOGINMESSAGE, userBean).commit();
    }

    @Override
    public String getUserBean() {
        return this.getSystemConfigSharedPreferences().getString(LOGINMESSAGE, "");
    }

    @Override
    public void setStatus(String status) {
        this.getSystemConfigSharedPreferences().edit()
                .putString(STATUS, status).commit();
    }

    @Override
    public String getStatus() {
        return this.getSystemConfigSharedPreferences().getString(STATUS,
                "");
    }

    @Override
    public void SetLogin(boolean islogin) {
        this.getSystemConfigSharedPreferences().edit()
                .putBoolean(ISLOGIN, islogin).commit();
    }

    @Override
    public boolean getLogin() {
        return this.getSystemConfigSharedPreferences().getBoolean(ISLOGIN,
                false);
    }

    @Override
    public void setUuid(String uuid) {
        this.getSystemConfigSharedPreferences().edit()
                .putString(ID, uuid).commit();
    }

    @Override
    public String getUuid() {
        return this.getSystemConfigSharedPreferences().getString(ID, "");
    }

    @Override
    public void setToken(String token) {
        this.getSystemConfigSharedPreferences().edit()
                .putString(TOKEN, token).commit();
    }

    @Override
    public String getToken() {
        return this.getSystemConfigSharedPreferences().getString(TOKEN, "");
    }

    @Override
    public void setUsername(String name) {
        this.getSystemConfigSharedPreferences().edit()
                .putString(USERNAME, name).commit();
    }

    @Override
    public String getUsername() {
        return this.getSystemConfigSharedPreferences().getString(USERNAME, "");
    }

    @Override
    public void setImageName(String imgname) {
        this.getSystemConfigSharedPreferences().edit()
                .putString(IMAGENAME, imgname).commit();
    }

    @Override
    public String getImageNmae() {
        return this.getSystemConfigSharedPreferences().getString(IMAGENAME, "");
    }

    @Override
    public void setUsersex(String sex) {
        this.getSystemConfigSharedPreferences().edit()
                .putString(USERSEX, sex).commit();
    }

    @Override
    public String getUsesex() {
        return this.getSystemConfigSharedPreferences().getString(USERSEX, "");
    }

    @Override
    public void setUserimg(String img) {
        this.getSystemConfigSharedPreferences().edit()
                .putString(USERIMG, img).commit();
    }

    @Override
    public String getUserimg() {
        return this.getSystemConfigSharedPreferences().getString(USERIMG, "");
    }

    @Override
    public void setUserimgName(String img) {
        this.getSystemConfigSharedPreferences().edit()
                .putString(IMAGNAME, img).commit();
    }

    @Override
    public String getUserimgName() {
        return this.getSystemConfigSharedPreferences().getString(IMAGNAME, "");
    }

    @Override
    public void setUseridcard(String idcard) {
        this.getSystemConfigSharedPreferences().edit()
                .putString(USERIDCARD, idcard).commit();
    }

    @Override
    public String getUseridcard() {
        return this.getSystemConfigSharedPreferences().getString(USERIDCARD, "");
    }

    @Override
    public void setJobLevel(String jobLevel) {
        this.getSystemConfigSharedPreferences().edit()
                .putString(JOBLEVEL, jobLevel).commit();
    }

    @Override
    public String getJobLevel() {
        return this.getSystemConfigSharedPreferences().getString(JOBLEVEL, "");
    }

    @Override
    public void setExclusiceSrc(String exclusiceSrc) {
        this.getSystemConfigSharedPreferences().edit()
                .putString(EXCLUSICESRC, exclusiceSrc).commit();
    }

    @Override
    public String getExclusiceSrc() {
        return this.getSystemConfigSharedPreferences().getString(EXCLUSICESRC, "");
    }

    @Override
    public void setUserMessage(String message) {
        this.getSystemConfigSharedPreferences().edit()
                .putString(USERMESSAGE, message).commit();
    }

    @Override
    public String getUserMessage() {
        return this.getSystemConfigSharedPreferences().getString(USERMESSAGE, "");
    }

    @Override
    public void setAddapp(String addapp) {
        this.getSystemConfigSharedPreferences().edit()
                .putString(ADDAPP, addapp).commit();
    }

    @Override
    public String getAddapp() {
        return this.getSystemConfigSharedPreferences().getString(ADDAPP, "");
    }

    @Override
    public void setDeleteapp(String deleteapp) {
        this.getSystemConfigSharedPreferences().edit()
                .putString(DELETEAPP, deleteapp).commit();
    }

    @Override
    public String getDeleteapp() {
        return this.getSystemConfigSharedPreferences().getString(DELETEAPP, "");
    }

    @Override
    public void setInsurance(String insurance) {
        this.getSystemConfigSharedPreferences().edit()
                .putString(INSURANCE, insurance).commit();
    }

    @Override
    public String getInaurance() {
        return this.getSystemConfigSharedPreferences().getString(INSURANCE, "");
    }


}
